
#import <Foundation/Foundation.h>
#import "BYRequestDelegate.h"
#import "../../MKNetworkKit/MKNetworkKit.h"
#import "NSString+SBJSON.h"

#define NETWORK_URL_PREFIX @"http://www.noahsecure.com"


/*******Change the request finish ways by block*
 added by xiangming
 ************/

typedef void(^BYRequestFinishBlock)(BYRequest *request, BYResponse *response);


@interface BYRequest : MKNetworkOperation

@property (nonatomic, assign) NSInteger tag;
@property (nonatomic, strong) NSDictionary *userInfo;
@property (nonatomic, unsafe_unretained) id<BYRequestDelegate> resultDelegate;

@property (nonatomic, strong) NSString *cookieStr;

/* request from cache, default NO */
@property (nonatomic, assign) BOOL requestCache;
@property (nonatomic, copy) NSString* responseCache;

@property (nonatomic, copy) BYRequestFinishBlock finishBlock;

/* replace startAsynchronous */
- (void)sendAsynchronous;
/* replace startSynchronous, fake synchronous */
- (void)sendSynchronous;

+ (BOOL)clearCache;

- (BOOL)clearCache;

//Subclass can override the methods to customize the request

- (NSString *)apiRequestMethod;
- (NSString *)apiURLPrefix;
- (NSString *)apiURLSuffix;
/* request param dictionary */
- (NSMutableDictionary *)parameters;
- (BOOL)validateParameters:(NSMutableString *)errorMessage;

- (Class)responseClass;


@end